<template>
  <div class="box">
    <h1>组件B，{{ num }}</h1>
    <van-button type="primary" @click="handlePlus">+</van-button>
    <div v-for="item in goods.filterList">
      名称{{ item.name }} 价格 {{ item.price }}
    </div>
  </div>
</template>

<script setup lang="ts">
import { storeToRefs } from "pinia";
import { useCount } from "../../store/count";
import { useGoods } from "../../store/goods";
let { num } = storeToRefs(useCount()); //如果不适用storeToRefs，num会失去响应性
//触发action
let count = useCount();
const handlePlus = () => {
  count.increment();
};

const goods = useGoods();
</script>

<style scoped>
.box {
  height: 400px;
  border: 1px solid #333;
}
</style>
